import java.util.Scanner;

public class TestDay24 {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[][]array = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = scanner.nextInt();
            }
        }
        func(array,0,0,0);
        for (int i = size-1; i >=0 ; i--) {
            System.out.println(str[i]);
        }
    }

    static String[] str = new String[100];
    static int size = 0;
    private static boolean func(int[][]array,int x,int y,int n) {
        //n是标志位
        //表示当前我是如何来的
        //1,2,3,4
        //上下左右

        if(x < 0 || y < 0 || x == array.length || y == array[0].length){
            return false;
        }
        if(array[x][y] == 1){
            return false;
        }
        if(x == array.length-1 && y == array[0].length-1){

           str[size++] = new String("("+x+","+y+")");
            return true;
        }
        //只要有一个为真就打印
         if(( n != 1&&func(array,x-1,y,2))||(n != 4&&func(array,x,y-1,3) )||(n != 2&&func(array,x+1,y,1) )||
                 (n !=3&&func(array,x,y+1,4))){
             str[size++] = new String("("+x+","+y+")");
             return true;
         }
        return false;
    }


    public int getMost(int[][] board) {
        // write code here

        //行
        int row = board.length;
        //列
        int col = board[0].length;

        //创建一个计数数组
        int[][]p = new int[row][col];
        // 处理第一行
        for (int i = 1; i < row; i++) {
            p[0][i] += p[0][i-1];
        }
        //处理第一列
        for (int i = 1; i < col; i++) {
            p[i][0] += p[i-1][0];
        }
        //处理剩余的
        for (int i = 1; i < row; i++) {
            for (int j = 1; j < col; j++) {
               board[i][j]+= Math.max(board[i][j-1],board[i-1][j]);
            }
        }
        System.out.println();
        return board[row-1][col-1];
    }




}
